#ifndef RECTANGLE_H
#define RECTANGLE_H

#include "icgobject.h"
#include "plane.h"
#include "point.h"

class Rectangle : public ICgObject
{
public:
    Rectangle(const Point &p1, const Point &p2, const Point &p3, const Point &p4);
    bool intersect(const Ray &r, double &t, Vector &normal) const;
    void openGlRender() const;
    ICgObject* clone() const;

private:
    Point p1_, p2_, p3_, p4_;
    Plane plane_;

    bool intersectTriangle(const Point &x, const Point &p1, const Point &p2, const Point &p3) const;
};

#endif // RECTANGLE_H
